<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags/form"  prefix="fm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'edit.jsp' starting page</title>
    <style type="text/css">
    	body{
    		margin:30px;
    	}
    	ul.errorMessage,ul.errorMessage li{
    		margin:0; 
    		padding:0;
    		list-style-type:none;
    		color:red;
    		display:inline;
    	}
    </style>
  </head>
  
  <body>
  	<form action="save"  method="post" enctype="multipart/form-data">
  	<input type="hidden" name="id" value="${movie==null?0:movie.id}" />
    <table border="1">
    	<caption>编辑电影</caption>
    	<tr><td>电影名称：</td>
    		<td><input type="text" name="title" value="${movie.title}" /></td>
    	</tr>
    	<tr><td>电影编号：</td>
    		<td><input type="text" name="movieCode" value="${movie.movieCode}" /></td>
    	</tr>
    	<tr><td>电影海报：</td>
    		<!-- ${pageContext.request.contextPath } -->
    		<td><img src="${initParam.url}/images/${movie.movieCode}.jpg"  width="180px"/>
    			<br/><input type="file" name="movieImage" /></td>
    	</tr>
    	<tr><td>分类：</td>
    		<td>
    			<select name="category.id">
    			<c:forEach var="c" items="${categories}">
    				<c:if test="${c.id==movie.category.id}">
    				<option value="${c.id}" selected="selected">${c.name}</option>
    				</c:if>
    				<c:if test="${c.id!=movie.category.id}">
    				<option value="${c.id}">${c.name}</option>
    				</c:if>
    			</c:forEach>
    			</select>
    		</td></tr>
    	<tr><td>导演:</td>
    		<td><input type="text" name="director" value="${movie.director}" /></td></tr>
    	<tr><td>上映时间：</td>
    		<td><input type="text" id="dateReleased" name="dateReleased" value='<fmt:formatDate value="${movie.dateReleased}"/>' /></td>
    	</tr>
    	<tr><td>&nbsp;</td>
    		<td><input type="submit" value="提交" /></td></tr>
    </table>
    </form>
    <div style="color:red;">
    	<fm:form commandName="movie">
    	  <fm:errors path="*"></fm:errors>
    	</fm:form>
    </div>
  </body>
</html>





